package com.jwgf.common;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class IOReader {
    public static int getIO() {
        String path = "/proc/hmi/gpios/mode";
        int value = 0;

        try {
            BufferedReader reader0 = new BufferedReader(new InputStreamReader(new FileInputStream(path + 0)));
            BufferedReader reader1 = new BufferedReader(new InputStreamReader(new FileInputStream(path + 1)));
            BufferedReader reader2 = new BufferedReader(new InputStreamReader(new FileInputStream(path + 2)));
            int mode0 = Integer.valueOf(reader0.readLine());
            int mode1 = Integer.valueOf(reader1.readLine());
            int mode2 = Integer.valueOf(reader2.readLine());
            value = Utility.BitUtils.setBitValue(value, 0, mode0);
            value = Utility.BitUtils.setBitValue(value, 1, mode1);
            value = Utility.BitUtils.setBitValue(value, 2, mode2);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return value;
    }
}
